package com.csu.cphone.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.csu.cphone.dao.RecycleSelectAnswerMapper;
import com.csu.cphone.pojo.RecycleSelectAnswerPojo;
import com.csu.cphone.service.RecycleSelectAnswerService;

/**
 * @项目名称：cphone
 * @类名称：RecycleSelectAnswerServiceImpl
 * @类描述：
 * @创建人：Tangc
 * @创建时间：2017年12月7日 下午10:23:48
 * @company:
 */
@Service
public class RecycleSelectAnswerServiceImpl implements RecycleSelectAnswerService
{

    @Autowired
    private RecycleSelectAnswerMapper recycleSelectAnswerMapper;

    /**
     * @see com.csu.cphone.service.RecycleSelectAnswerService#deleteById(java.lang.Integer)
     */
    @Override
    public Integer deleteById(Integer recycleProblemId)
    {
        return recycleSelectAnswerMapper.deleteById(recycleProblemId);
    }

    /**
     * @see com.csu.cphone.service.RecycleSelectAnswerService#queryList(java.lang.Integer,
     *      java.lang.Integer, java.lang.String)
     */
    @Override
    public List<RecycleSelectAnswerPojo> queryList(Integer pageSize, Integer startIndex, String order,
            String recycleOrderSn)
    {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("pageSize", pageSize);
        map.put("startIndex", startIndex);
        map.put("order", order);
        if (recycleOrderSn != null)
        {
            map.put("recycleOrderSn", recycleOrderSn);
        }
        return recycleSelectAnswerMapper.queryList(map);
    }

    /**
     * @see com.csu.cphone.service.RecycleSelectAnswerService#count()
     */
    @Override
    public Integer count(String recycleOrderSn)
    {
        return recycleSelectAnswerMapper.count(recycleOrderSn);
    }

    /**
     * @see com.csu.cphone.service.RecycleSelectAnswerService#queryById(java.lang.Integer)
     */
    @Override
    public RecycleSelectAnswerPojo queryById(Integer recycleProblemId)
    {
        return recycleSelectAnswerMapper.selectById(recycleProblemId);
    }

    /**
     * @see com.csu.cphone.service.RecycleSelectAnswerService#update(com.csu.cphone.pojo.RecycleSelectAnswerPojo)
     */
    @Override
    public Integer update(RecycleSelectAnswerPojo selectPojo)
    {
        return recycleSelectAnswerMapper.update(selectPojo);
    }

    /**
     * @see com.csu.cphone.service.RecycleSelectAnswerService#add(java.lang.Integer,
     *      java.lang.String, java.lang.Integer, java.lang.Integer,
     *      java.lang.Double)
     */
    @Override
    public RecycleSelectAnswerPojo add(Integer recyclePhoneId, String recycleOrderSn, Integer recycleProblemId,
            Integer recycleProblemSelectId, Double cost)
    {
        RecycleSelectAnswerPojo recycleSelectAnswer = new RecycleSelectAnswerPojo();
        recycleSelectAnswer.setCost(cost);
        recycleSelectAnswer.setRecycleOrderSn(recycleOrderSn);
        recycleSelectAnswer.setRecyclePhoneId(recyclePhoneId);
        recycleSelectAnswer.setRecycleProblemId(recycleProblemId);
        recycleSelectAnswer.setRecycleProblemSelectId(recycleProblemSelectId);
        recycleSelectAnswerMapper.insert(recycleSelectAnswer);
        return recycleSelectAnswer;
    }

}
